<%@page import="team02.server.bean.UserBean"%>
<%@page import="org.apache.commons.lang.StringUtils"%>
<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>

<%@page
	import="team02.server.core.servlet.TestControllerDispatcher.RequestWrapper"%>
<%@page import="java.sql.SQLException"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script src="${pageContext.request.contextPath}/js/jquery.min.js"></script>
<script
	src="//ajax.microsoft.com/ajax/jquery.validate/1.7/jquery.validate.min.js"></script>

<link href="${pageContext.request.contextPath}/css/template.css"
	rel="stylesheet" type="text/css" />
<script type="text/javascript"
	src="${pageContext.request.contextPath}/js/allpage.js"></script>
<jsp:useBean id="orgBean" class="team02.server.bean.OrganizationBean"
	scope="session"></jsp:useBean>
<jsp:useBean id="userBean" class="team02.server.bean.UserBean"
	scope="session"></jsp:useBean>
<jsp:useBean id="examineeBean" class="team02.server.bean.ExamineeBean"
	scope="session"></jsp:useBean>

<%
	//ログアウトした後、戻ることできない
	response.setHeader("Cache-Control", "no-cache");
	response.setHeader("Cache-Control", "no-store");
	response.setHeader("Pragma", "no-cache");
	response.setDateHeader("Expires", 0);
	//ログインチェック
	if (!orgBean.checkAliasRequest(request.getParameter("aliasRequest"))) {//khong ton tai doan the
		userBean.clear();
		response.sendRedirect("404.html");
		return;
	} else if (userBean.getAlias() != null && !request.getParameter("aliasRequest").equals(userBean.getAlias())) {// doan the ko trung voi nguoi dang dang nhap
		userBean.clear();
		response.sendRedirect("error.t02");
		return;
	} else if (!"login.t02".equals(request.getParameter("targetPage"))) {
		if ("test_page.t02".equals(request.getParameter("targetPage"))) {//check examinee or test maker
			if (userBean.getUserId() != 0) {

				if (userBean.getAccessLevel() == UserBean.LEVEL_TEST_MAKER
						|| userBean.getAccessLevel() == UserBean.LEVEL_ORG_ADMIN) {//simulation
					((RequestWrapper) request).addParameter("simulation", "true");
				} else {
					response.sendRedirect("404.html");
				}
			} else if (examineeBean.getId() == 0) {//examinee has not login yet
				response.sendRedirect("login.t02?prev=test_page.t02&u=" + request.getParameter("u") + "&t="
						+ request.getParameter("t"));
			}
		} else if (userBean.getUserId() == 0) { //まだログインしていない!
			response.sendRedirect("login.t02");
			return;
		}
	}
%>
<title>${param.pageTitle}</title>
</head>
<body>
	<div class="header"></div>